package two.chapter_1.c1_1;

import edu.princeton.cs.algs4.StdOut;
import edu.princeton.cs.algs4.StdRandom;

public class Ex1_1_35 {

    public static void main(String[] args) {


        int SIZES=6;
        double[]dist=new double[2*SIZES+1];

        for (int i=1;i<=SIZES;i++){
            for (int j=1;j<=SIZES;j++){
                dist[i+j]+=1.0;
            }
        }
        for (int k=2;k<=2*SIZES;k++){
            dist[k]/=36.0;
        }


        int N=1000000;
        double [] result=new double[2*SIZES+1];
        for (int i=0;i<N;i++){

           int a=StdRandom.uniform(1,6+1);
           int b=StdRandom.uniform(1,6+1);
           result[a+b]+=1;
        }


        //测出的频率
        for (int i=2;i<=2*SIZES;i++){
            result[i]/=N;

            boolean flag=Math.abs(dist[i]-result[i])<=0.001;
            StdOut.println("i:"+i+"-"+flag);
        }



    }





}
